package testobjects;

import java.awt.Graphics2D;
import java.io.File;
import java.util.zip.DataFormatException;

import com.golden.gamedev.Game;
import com.golden.gamedev.object.Timer;

@SuppressWarnings("serial")
public class Fish extends AbstractGameObject {
    
    public Fish(Game game)
    {
        super(game);
    }

    public Fish(Game game, File file)
    {
        super(game, file);
        this.setLocation(game.getWidth() / 2 - getWidth() / 2, game.getHeight() - (getHeight() * 2));
    }
    
    public void render(Graphics2D g)
    {
        if(myGame.click())
        {
            g.scale(2, 2);
            System.out.println(";alskdjf");
        }
        super.render(g);
    }


    @Override
    public void update(long elapsedTime) {
        super.update(elapsedTime);
        this.handleUserInput(elapsedTime);
        
        if (getAnimationTimer().action(elapsedTime)) {
            getAnimationTimer().refresh();
            updateAnimation();
        }
    }


    @Override
    protected void handleUserInput(long elapsedTime) 
    {
        if(myGame.checkPosMouse(0, 0, myGame.getWidth(), myGame.getHeight()))
        {
            this.moveTo(elapsedTime, myGame.getMouseX() - getWidth() / 2, myGame.getHeight() - (getHeight() * 2), 1);
        }
                

        if (myGame.click()) {
            System.out.println("here");
            Graphics2D temp = myGame.bsGraphics.getBackBuffer();
            temp.scale(2, 2);
            this.render(temp);
        }
    }



//    private void launchProjectile() {
//        Bubble bubble = new Bubble(myGame);
//        bubble.setX(50);
//        bubble.setY(50);
//        bubble.setVerticalSpeed(0);
//        bubble.setActive(true);
//    }
}
